<template>
  <div class="all-rel">
    <div class="all-flex-center-start all-top-handle">
      <span>今日核销数：<i>{{statistics.today_count}}</i></span>
      <span>昨日核销数：<i>{{statistics.yestoday_count}}</i></span>
      <span>总核销数：<i>{{statistics.all_count}}</i></span>
    </div>
    <div class="all-flow-table-box">
      <el-table ref="myTable" :data="list" border stripe>
        <el-table-column type="index" align="center" width="50"></el-table-column>
        <el-table-column align="center" prop="productName" label="产品名称" width="180"></el-table-column>
        <el-table-column align="center" prop="verificationCode" label="核销码" width="200"></el-table-column>
        <el-table-column sortable align="center" prop="addTime" label="核销时间" width="180"></el-table-column>
        <el-table-column></el-table-column>
      </el-table>
    </div>
    <div class="all-pagination">
      <el-pagination background layout="prev, pager, next" :page-size="size" :total="count" @current-change="currentPage"></el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      count: 0,
      size: 10,
      statistics: {},
      list: [],
      masterID: ''
    };
  },
  methods: {
    clearFilter() {
      this.$refs.myTable.clearFilter();
    },
    getList(page, size) {
      let _this = this;
      this.$ajax({
        url:'order/getCompleteCode',
        data:{
          app:{
            masterID: this.masterID,
            page: page,
            size: size === undefined ? this.size : size,
          }
        },
        perfect(con) {
          _this.list = con.list;
          _this.count = con.count;
        },
        success(res) {
          if (res.data.code !== 1) {
            _this.$message({
              message: res.data.msg,
              type: 'warning'
            });
          }
        }
      });
    },
    currentPage(page) {
      this.getList(page);
    }
  },
  created(){
    let _this = this;
    this.masterID = this.$store.state.user.userId;
    this.getList(1);
    //获取统计数据
    this.$ajax({
      url: 'index/masterVerification',
      data:{
        app:{
          masterID: this.masterID
        }
      },
      perfect(con) {
        _this.statistics = con;
      }
    });
  }
};
</script>
<style scoped>
.all-top-handle span {
  margin-right: 30px;
  color: #666;
}
.all-top-handle span i {
  font-style: normal;
  font-size: 20px;
}
</style>
